/* Search Container Styles */
.search-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 调整搜索框样式以匹配其他控件 */
.search-container input {
    width: 100%;
    padding: 6px 35px 6px 12px; /* Reduced right padding */
    border: 1px solid oklch(65% 0.02 256);
    border-radius: var(--border-radius-sm);
    background: var(--lora-surface);
    color: var(--text-color);
    font-size: 0.9em;
    height: 32px;
    box-sizing: border-box;
}

.search-container input:focus {
    outline: none;
    border-color: var(--lora-accent);
}

.search-icon {
    position: absolute;
    right: 80px; /* Adjusted to make space for both toggle buttons */
    top: 50%;
    transform: translateY(-50%);
    color: oklch(var(--text-color) / 0.5);
    pointer-events: none;
    line-height: 1;
}

/* 修改清空按钮样式 */
.search-clear {
    position: absolute;
    right: 105px; /* Adjusted further left to avoid overlapping */
    top: 50%;
    transform: translateY(-50%);
    color: oklch(var(--text-color) / 0.5);
    cursor: pointer;
    border: none;
    background: none;
    padding: 4px 8px;
    display: none;
    line-height: 1;
    transition: color 0.2s ease;
}

.search-clear:hover {
    color: var(--lora-accent);
}

.search-clear.visible {
    display: block;
}

.search-mode-toggle {
    background: var(--lora-surface);
    border: 1px solid oklch(65% 0.02 256);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.search-mode-toggle:hover {
    background-color: var(--lora-surface-hover, oklch(95% 0.02 256));
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-mode-toggle.active {
    background-color: oklch(95% 0.05 256); /* Lighter background that's more consistent */
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-mode-toggle i {
    font-size: 0.9em;
}

.search-filter-toggle {
    background: var(--lora-surface);
    border: 1px solid oklch(65% 0.02 256);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.search-filter-toggle:hover {
    background-color: var(--lora-surface-hover, oklch(95% 0.02 256));
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-filter-toggle.active {
    background-color: oklch(95% 0.05 256); /* Lighter background that's more consistent */
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-filter-toggle i {
    font-size: 0.9em;
}

.filter-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: var(--lora-accent);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Filter Panel Styles */
.filter-panel {
    position: fixed;
    right: 20px;
    top: 50px; /* Position below header */
    width: 320px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-base);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-overlay);
    padding: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: top right;
    max-height: calc(100vh - 70px); /* Adjusted for header height */
    overflow-y: auto;
}

.filter-panel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.filter-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.close-filter-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-filter-btn:hover {
    color: var(--lora-accent);
}

.filter-section {
    margin-bottom: 16px;
}

.filter-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-tag {
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    background-color: var(--lora-surface);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none; /* For Safari */
    -moz-user-select: none; /* For Firefox */
    -ms-user-select: none; /* For IE/Edge */
}

.filter-tag:hover {
    background-color: var(--lora-surface-hover);
}

.filter-tag.active {
    background-color: var(--lora-accent);
    color: white;
    border-color: var(--lora-accent);
}

/* Tag filter styles */
.tag-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 60px;
}

.tag-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-left: 4px;
}

[data-theme="dark"] .tag-count {
    background: rgba(255, 255, 255, 0.1);
}

.tag-filter.active .tag-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.tags-loading, .tags-error, .no-tags {
    width: 100%;
    padding: 8px;
    text-align: center;
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.7;
}

.tags-error {
    color: var(--lora-error);
}

/* Filter actions */
.filter-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
    gap: 8px;
}

.clear-filters-btn {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
}

.clear-filters-btn:hover {
    background-color: var(--lora-surface-hover);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .search-container {
        width: 100%;
        order: -1;
        margin-left: 0;
        margin-right: 0;
    }
    
    .filter-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        top: 160px; /* Adjusted for mobile layout */
    }
}

/* Search Options Toggle */
.search-options-toggle {
    background: var(--lora-surface);
    border: 1px solid oklch(65% 0.02 256);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.search-options-toggle:hover {
    background-color: var(--lora-surface-hover, oklch(95% 0.02 256));
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-options-toggle.active {
    background-color: oklch(95% 0.05 256);
    color: var(--lora-accent);
    border-color: var(--lora-accent);
}

.search-options-toggle i {
    font-size: 0.9em;
}

/* Search Options Panel */
.search-options-panel {
    position: fixed;
    right: 20px;
    top: 50px; /* Position below header */
    width: 280px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-base);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-overlay);
    padding: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: top right;
    display: block; /* Ensure it's block by default */
}

.search-options-panel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.options-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-color);
}

.close-options-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-options-btn:hover {
    color: var(--lora-accent);
}

.options-section {
    margin-bottom: 16px;
}

.options-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
}

.search-option-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Increased gap for better spacing */
}

.search-option-tag {
    padding: 6px 8px; /* Adjusted padding for better text display */
    border-radius: var(--border-radius-sm);
    background-color: var(--lora-surface);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 13px; /* Slightly smaller font size */
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    flex: 1;
    text-align: center;
    white-space: nowrap; /* Prevent text wrapping */
    min-width: 80px; /* Ensure minimum width for each tag */
    display: inline-flex; /* Better control over layout */
    justify-content: center;
    align-items: center;
}

.search-option-tag:hover {
    background-color: var(--lora-surface-hover);
}

.search-option-tag.active {
    background-color: var(--lora-accent);
    color: white;
    border-color: var(--lora-accent);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-options-panel,
    .filter-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        top: 160px; /* Adjusted for mobile layout */
    }
}